import request from './request'

export function insertOrUpdateRoom(data:any) {
    return request({
        url: '/room',
        method: 'post',
        data
    })
}

export function searchRooms(data:any, page:number, pageSize:number) {
    return request({
        url: '/room/search?page='+page+'&pageSize='+pageSize,
        method: 'post',
        data
    })
}

export function getRoomById(id:number) {
    return request({
        url: '/room/'+id,
        method: 'get'
    })
}

export function getMembers(id:number) {
    return request({
        url: '/room/members/'+id,
        method: 'get'
    })
}

export function quitRoom(data:any) {
    return request({
        url: '/rooom/members/quit',
        method: 'post',
        data
    })
}

export function deleteMemebers(data:any, uid:string, username:string) {
    return request({
        url: '/room/members/delete/'+uid+'/'+username,
        method: 'post',
        data
    })
}

export function applyJoinRoom(data:any) {
    return request({
        url: '/room/apply',
        method: 'post',
        data
    })
}

export function dealWithApply(data:any, uid:string, flag:boolean) {
    return request({
        url: '/room/dealWithApply/'+uid+'/'+flag,
        method: 'post',
        data
    })
}

export function sendMessageFiles(data:any) {
    return request({
        url: '/room/messages/files',
        method: 'post',
        data
    })
}

export function getRoomMessages(roomId:number) {
    return request({
        url: '/room/messages/'+roomId,
        method: 'get'
    })
}

export function bindRoomCharacter(roomId:number, characterId: number) {
    return request({
        url: '/room/bindCharacter/'+roomId+'/'+characterId,
        method: 'post'
    })
}

export function bindRoomScript(roomId:number, scriptId: number) {
    return request({
        url: '/room/bindScript/'+roomId+'/'+scriptId,
        method: 'post'
    })
}